# 创建插入数据sql语句的脚本

import random

def generate_user_data(index):
    first_names = ['张', '李', '王', '赵', '孙', '周', '吴', '郑', '钱']
    second_names = ['三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二', '十三', '十四', '十五', '十六', '十七', '十八', '十九', '二十', '二十一', '二十二']

    user_name = first_names[index % len(first_names)] + second_names[index % len(second_names)]
    gender = random.randint(0, 1)
    student_or_work_number = 20170001 + index
    age = random.randint(20, 30)
    role = random.randint(0, 1)
    password = user_name + 'Pass'
    
    return f"('{user_name}', {gender}, {student_or_work_number}, {age}, {role}, '{password}')"

def generate_sql_file(user_count, file_name="users.sql"):
    sql_header = "INSERT INTO `User` (`user_name`, `gender`, `StudentOrWorkNumber`, `age`, `role`, `password`) VALUES\n"
    sql_values = ",\n".join(generate_user_data(i) for i in range(user_count)) + ";"
    
    with open(file_name, 'w', encoding='utf-8') as file:
        file.write(sql_header + sql_values)
        
    print(f"SQL file '{file_name}' with {user_count} users generated successfully.")

# Example usage: generate SQL file with 20 users
generate_sql_file(10000)
